package in.muton.panels.paginator.helpers.deletelinks;

import in.muton.edushare.pages.common.EdusharePanel;
import in.muton.panels.paginator.badgehelpers.course.CourseBadgeInterface;

import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.IModel;

import com.edushare.common.vo.Courses;

public class CourseDelete extends Link<Void> {
	private static final long serialVersionUID = -6983892540874301358L;

	public CourseDelete(String id, EdusharePanel panel,
			CourseBadgeInterface bif, IModel<Courses> courseModel) {
		super(id);
		this.panel = panel;
		this.courseModel = courseModel;
		this.bif = bif;
	}

	@Override
	public void onClick() {
		if (bif != null)
			panel.setError(bif.removeCourse(courseModel));
	}

	@Override
	public boolean isVisible() {
		return bif != null && bif.isAdmin();
	}

	private IModel<Courses> courseModel;
	EdusharePanel panel = null;
	private CourseBadgeInterface bif;
}